import { GET_OSS_IMGPATH, OSS_HOST } from '@/config'

export function getImgUrl(fileName, styleName) {
	styleName = styleName || 'photo1'
	if (fileName) {
		if (fileName.indexOf('http') == 0) {
            return fileName + '!' + styleName
        } else if (fileName.indexOf('blob') == 0) {
            return fileName
        }
        return OSS_HOST + fileName + '!' + styleName
	}
	return ''
}

export function getImgUrls(fileList, styleName) {
	styleName = styleName || 'photo1'
    let ret = []
	if (fileList) {
        fileList.forEach(function(currentValue, index){
            if (currentValue.photo) {
                ret.push(getImgUrl(currentValue.photo, styleName))
            }
        })
	}
	return ret
}
